<html>

<head>
    <title>{{ title }} - My Flask Application</title>
</head>

<body>
    <div>
        已签到人数：{{count1}}
    </div>

    <div>
        <input id='txtName' /> <button onclick="sign()">签到</button>
    </div>

    <script src="/static/jquery-1.10.2.js"></script>
    <script>
        function sign() {
            var name = $('#txtName').val();
            // var data=JSON.stringify({name:name});
            // $.post('/sign_data',data,'application/json; charset=utf-8')
            // .success(function(){
            //     alert('签到成功');
            // })
            // .error(function(msg){
            //     alert(msg);
            // })
            var model = JSON.stringify({ name: name });
            $.ajax({
                url: '/sign_data',
                type: 'post',
                dataType: 'json',
                headers: {
                    "Content-Type": "application/json;charset=utf-8"
                },
                contentType: 'application/json; charset=utf-8',
                data: model,
                success: function (data) {
                    alert('签到成功');
                },
                error: function (data) {
                    alert('保存失败');
                }
            })
        }
    </script>
</body>

</html>